<%={{ }}=%>
{{#program:services}}
  "{{service:name}}" : {
    "name" : "{{service:name}}",
    "lineno" : {{service:lineno}},
    {{#service:docstring?}}
    "docstring" : "{{service:docstring}}",
    {{/service:docstring?}}
    "functions" : {
      {{#service:functions?}}
      {{#service:functions}}
      "{{function:name}}" : {
        "name" : "{{function:name}}",
        {{#function:docstring?}}
        "docstring" : "{{function:docstring}}",
        {{/function:docstring?}}
        {{#function:args?}}
        "args" : {
          {{#function:args}}
          "{{field:name}}": {
            "name" : "{{field:name}}",
            "type" : {{#field:type}}{{> Types}}{{/field:type}},
            {{#field:value}}
            "default_value" : {{> const_value}},
            {{/field:value}}
            {{#field:docstring?}}
            "docstring" : "{{field:docstring}}",
            {{/field:docstring?}}
            "key" : {{field:key}},
            "lineno" : {{field:lineno}},
            {{#field:required?}}
            "required" : "required",
            {{/field:required?}}
            {{#field:optional?}}
            "required" : "optional",
            {{/field:optional?}}
            {{#field:optInReqOut?}}
            "required" : "opt-in-req-out"
            {{/field:optInReqOut?}}
          }{{^last?}},{{/last?}}
          {{/function:args}}
        },
        {{/function:args?}}
        {{#function:exceptions?}}
        "exceptions" : {
          {{#function:exceptions}}
          "{{field:name}}" : {
            "name": "{{field:name}}",
            "type" : {{#field:type}}{{> Types}}{{/field:type}}
          }{{^last?}},{{/last?}}
          {{/function:exceptions}}
        },
        {{/function:exceptions?}}
        "returnType" : {{#function:returnType}}{{> Types}}{{/function:returnType}},
        "lineno" : {{function:lineno}}
      }{{^last?}},{{/last?}}
      {{/service:functions}}
      {{/service:functions?}}
    }{{^last?}},{{/last?}}
  }{{^last?}},{{/last?}}
{{/program:services}}
